/*     */ package com.iris.egrant.web.struts2.tags;
/*     */ 
/*     */ import com.iris.egrant.app.utils.IrisStringUtils;
/*     */ import com.iris.egrant.utils.JsonUtils;
/*     */ import freemarker.template.Configuration;
/*     */ import freemarker.template.Template;
/*     */ import java.io.Writer;
/*     */
/*     */ import java.util.HashMap;
/*     */ import java.util.Map;
/*     */ import javax.servlet.jsp.JspException;
/*     */ import javax.servlet.jsp.tagext.BodyTagSupport;
/*     */ import net.sf.json.JSONArray;
/*     */ import net.sf.json.JSONSerializer;
/*     */ import org.apache.commons.lang.StringUtils;
/*     */ import org.springframework.context.i18n.LocaleContextHolder;
/*     */ import org.springframework.context.support.ResourceBundleMessageSource;
/*     */ import org.springframework.web.context.WebApplicationContext;
/*     */ import org.springframework.web.context.support.WebApplicationContextUtils;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class PieChartTag
/*     */   extends BodyTagSupport
/*     */ {
/*     */   private static final long serialVersionUID = 1077194066541229822L;
/*  35 */   private String id = "";
/*     */   
/*  37 */   private String key = "";
/*     */   
/*  39 */   private String dataObj = "";
/*     */ 
/*     */   
/*  42 */   private String contentObj = "";
/*     */   
/*  44 */   private String titleObj = "";
/*     */   
/*  46 */   private String locale = "";
/*     */   
/*  48 */   private String direction = "";
/*     */ 
/*     */   
/*  51 */   private String sqlParamVal = "";
/*     */   
/*     */   public String getDataObj() {
/*  54 */     return this.dataObj;
/*     */   }
/*     */   
/*     */   public void setDataObj(String dataObj) {
/*  58 */     this.dataObj = dataObj;
/*     */   }
/*     */   
/*     */   public String getContentObj() {
/*  62 */     return this.contentObj;
/*     */   }
/*     */   
/*     */   public void setContentObj(String contentObj) {
/*  66 */     this.contentObj = contentObj;
/*     */   }
/*     */   
/*     */   public String getTitleObj() {
/*  70 */     return this.titleObj;
/*     */   }
/*     */   
/*     */   public void setTitleObj(String titleObj) {
/*  74 */     this.titleObj = titleObj;
/*     */   }
/*     */   
/*     */   public String getDirection() {
/*  78 */     return this.direction;
/*     */   }
/*     */   
/*     */   public void setDirection(String direction) {
/*  82 */     this.direction = direction;
/*     */   }
/*     */   
/*     */   public String getLocale() {
/*  86 */     if (IrisStringUtils.isNullOrBlank(this.locale)) {
/*  87 */       return LocaleContextHolder.getLocale().toString();
/*     */     }
/*  89 */     return this.locale;
/*     */   }
/*     */   
/*     */   public void setLocale(String locale) {
/*  93 */     this.locale = locale;
/*     */   }
/*     */ 
/*     */   
/*     */   public int doStartTag() throws JspException {
/*  98 */     WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(this.pageContext.getServletContext());
/*     */ 
/*     */     
/* 101 */     Configuration cptFreemarkereConfiguration = (Configuration)ctx.getBean("cptFreemarkereConfiguration");
/*     */     
/* 103 */     ResourceBundleMessageSource messageSource = (ResourceBundleMessageSource)ctx.getBean("messageSource");
/*     */     
/*     */     try {
/* 106 */       if (!IrisStringUtils.isNullOrBlank(this.titleObj)) {
/*     */         
/* 108 */         Map<String, Object> titleObjMap = JsonUtils.getMap4Json(this.titleObj);
/* 109 */         String tiltleNameKey = (String)titleObjMap.get("name");
/* 110 */         if (!IrisStringUtils.isNullOrBlank(tiltleNameKey)) {
/*     */           
/* 112 */           tiltleNameKey = messageSource.getMessage(tiltleNameKey, null, tiltleNameKey, LocaleContextHolder.getLocale());
/*     */ 
/*     */           
/* 115 */           titleObjMap.put("name", tiltleNameKey);
/* 116 */           this.titleObj = JsonUtils.getJsonString4JavaPOJO(titleObjMap);
/*     */         } 
/*     */       } 
/*     */ 
/*     */       
/* 121 */       if (!IrisStringUtils.isNullOrBlank(this.dataObj)) {
/*     */         
/* 123 */         Map<String, Object> dataObjMap = JsonUtils.getMap4Json(this.dataObj);
/* 124 */         JSONArray dataObjKeyAry = (JSONArray)dataObjMap.get("name");
/*     */         int i;
/* 126 */         for (i = 0; i < dataObjKeyAry.size(); i++) {
/*     */           
/* 128 */           String dataObjKey = dataObjKeyAry.getString(i);
/*     */           
/* 130 */           if (!IrisStringUtils.isNullOrBlank(dataObjKey))
/*     */           {
/* 132 */             if (dataObjKey.contains("-")) {
/*     */               
/* 134 */               String dataObjKeyTmp = messageSource.getMessage(StringUtils.substringAfter(dataObjKey, "-"), null, StringUtils.substringAfter(dataObjKey, "-"), LocaleContextHolder.getLocale());
/*     */ 
/*     */ 
/*     */               
/* 138 */               dataObjKeyAry.set(i, StringUtils.substringBefore(dataObjKey, "-") + "-" + dataObjKeyTmp);
/*     */             } else {
/*     */               
/* 141 */               dataObjKey = messageSource.getMessage(dataObjKey, null, dataObjKey, LocaleContextHolder.getLocale());
/*     */ 
/*     */               
/* 144 */               dataObjKeyAry.set(i, dataObjKey);
/*     */             } 
/*     */           }
/*     */         } 
/*     */ 
/*     */ 
/*     */         
/* 151 */         dataObjMap.put("name", dataObjKeyAry);
/*     */ 
/*     */         
/* 154 */         dataObjKeyAry = (JSONArray)dataObjMap.get("href");
/*     */         
/* 156 */         for (i = 0; i < dataObjKeyAry.size(); i++) {
/* 157 */           String dataObjKey = dataObjKeyAry.getString(i);
/* 158 */           if (!IrisStringUtils.isNullOrBlank(dataObjKey) && dataObjKey.contains(".asp")) {
/*     */             
///* 160 */             String url = "/Include/cas.asp?roleId=" + SecurityUtils.getCurrentUserRoleId() + "&target_url=" + URLEncoder.encode(dataObjKeyAry.getString(i).trim(), "UTF-8");
/*     */             
///* 162 */             dataObjKeyAry.set(i, url);
/*     */           } 
/*     */         } 
/*     */ 
/*     */         
/* 167 */         dataObjMap.put("href", dataObjKeyAry);
/*     */         
/* 169 */         this.dataObj = JsonUtils.getJsonString4JavaPOJO(dataObjMap);
/*     */       } 
/*     */ 
/*     */       
/* 173 */       String res = (String)this.pageContext.getAttribute("res");
/* 174 */       Map<String, Object> params = new HashMap<String, Object>();
/* 175 */       params.put("key", this.key);
/* 176 */       params.put("id", this.id);
/* 177 */       params.put("sqlParamVal", this.sqlParamVal);
/*     */       
/* 179 */       Map<String, Object> rootMap = new HashMap<String, Object>();
/* 180 */       rootMap.put("res", res);
/* 181 */       rootMap.put("locale", getLocale());
/* 182 */       rootMap.put("id", this.id);
/* 183 */       rootMap.put("key", this.key);
/* 184 */       rootMap.put("params", JSONSerializer.toJSON(params).toString());
/* 185 */       rootMap.put("dataObj", this.dataObj);
/* 186 */       rootMap.put("contentObj", this.contentObj);
/* 187 */       rootMap.put("titleObj", this.titleObj);
/* 188 */       rootMap.put("direction", this.direction);
/*     */       
/* 190 */       Template template = cptFreemarkereConfiguration.getTemplate("pieChart.ftl", "utf-8");
/*     */       
/* 192 */       template.process(rootMap, (Writer)this.pageContext.getOut());
/*     */     }
/* 194 */     catch (Exception e) {
/* 195 */       throw new JspException(e);
/*     */     } 
/*     */     
/* 198 */     return 0;
/*     */   }
/*     */ 
/*     */   
/*     */   public String getId() {
/* 203 */     return this.id;
/*     */   }
/*     */ 
/*     */   
/*     */   public void setId(String id) {
/* 208 */     this.id = id;
/*     */   }
/*     */   
/*     */   public String getKey() {
/* 212 */     return this.key;
/*     */   }
/*     */   
/*     */   public void setKey(String key) {
/* 216 */     this.key = key;
/*     */   }
/*     */   
/*     */   public String getSqlParamVal() {
/* 220 */     return this.sqlParamVal;
/*     */   }
/*     */   
/*     */   public void setSqlParamVal(String sqlParamVal) {
/* 224 */     this.sqlParamVal = sqlParamVal;
/*     */   }
/*     */ }


/* Location:              D:\文件kjt\WEB-INF\lib\egrant-core-2.2.20240205.1659.jar!\com\iris\egrant\web\struts2\tags\PieChartTag.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       1.1.3
 */